package cn.gok.lambda;

import java.awt.print.Book;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;

public class Stream操作续 {
    public static void main(String[] args) {
        终止操作reduce();
    }

    private static void 终止操作reduce() {
        List<BigInteger> list=Arrays.asList(new BigInteger("10"),
                new BigInteger("20"),
                new BigInteger("30"),
                new BigInteger("30"));
        //1求和
        BigInteger result=list.stream().reduce(BigInteger.ZERO,BigInteger::add);
        System.out.println("和："+result);
        //求乘积
        BigInteger result2=list.stream().reduce(BigInteger.ONE,BigInteger::multiply);
        System.out.println("积："+result2);
    }
}

